/**
 * @Auther: ChenforCode
 * @Date: 2018/9/12 00:12
 * @Description: 完成与AdminBookRecord表相关的操作
 */
package cn.chenforcode.dao;

import cn.chenforcode.entity.AdminBookRecord;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Repository
@Transactional
public class AdminBookRecordDAO {
    @Autowired
    private SessionFactory sessionFactory;

    public Session getSession() {
        return sessionFactory.getCurrentSession();
    }

    /**
     * @return void
     * @Author ChenforCode
     * @Description //TODO 新增一条图书管理员操作图书的记录
     * @Date 0:13 2018/9/12
     * @Param [adminBookRecordDAO]
     **/
    public void addAdminBookRecord(AdminBookRecord adminBookRecord) {
        this.getSession().save(adminBookRecord);
    }

    /**
     * @return java.util.List<cn.chenforcode.entity.AdminBookRecord>
     * @Author ChenforCode
     * @Description //TODO 获得所有的图书管理员操作图书的记录
     * @Date 0:14 2018/9/12
     * @Param []
     **/
    public List<AdminBookRecord> getAllAdminBookRecords() {
        return this.getSession().createQuery("from AdminBookRecord").list();
    }
}
